/*     */ package com.zimbra.cs.mailclient.imap;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public final class Chars
/*     */ {
/*  32 */   public static final boolean[] ATOM_CHARS = new boolean['Ā'];
/*  33 */   public static final boolean[] ASTRING_CHARS = new boolean['Ā'];
/*  34 */   public static final boolean[] TAG_CHARS = new boolean['Ā'];
/*  35 */   public static final boolean[] FETCH_CHARS = new boolean['Ā'];
/*  36 */   public static final boolean[] NUMBER_CHARS = new boolean['Ā'];
/*  37 */   public static final boolean[] TEXT_CHARS = new boolean['Ā'];
/*  38 */   public static final boolean[] CAPABILITY_CHARS = new boolean['Ā'];
/*     */   private static final String QUOTED_SPECIALS = "\"\\";
/*     */   private static final String ASTRING_SPECIALS = "(){%*\"\\";
/*     */   private static final String ATOM_SPECIALS = "(){%*\"\\]";
/*     */   
/*     */   static
/*     */   {
/*  45 */     for (int i = 33; i < 127; i++) {
/*  46 */       ATOM_CHARS[i] = (ASTRING_CHARS[i] = TAG_CHARS[i] = FETCH_CHARS[i] = CAPABILITY_CHARS[i] = 1);
/*     */     }
/*     */     
/*  49 */     for (int i = 1; i < 128; i++) {
/*  50 */       TEXT_CHARS[i] = true;
/*     */     }
/*  52 */     set(ATOM_CHARS, "(){%*\"\\]", false);
/*  53 */     set(ASTRING_CHARS, "(){%*\"\\", false);
/*  54 */     set(TAG_CHARS, "(){%*\"\\+", false);
/*  55 */     set(FETCH_CHARS, "(){%*\"\\][]", false);
/*  56 */     set(NUMBER_CHARS, "0123456789", true);
/*  57 */     set(TEXT_CHARS, "\000\r\n", false);
/*  58 */     set(CAPABILITY_CHARS, "\"\\]", false);
/*     */   }
/*     */   
/*     */   private static void set(boolean[] ba, String chars, boolean b) {
/*  62 */     for (int i = 0; i < chars.length(); i++) {
/*  63 */       ba[chars.charAt(i)] = b;
/*     */     }
/*     */   }
/*     */   
/*     */   public static boolean isNumber(char c) {
/*  68 */     return (c < 'Ā') && (NUMBER_CHARS[c] != 0);
/*     */   }
/*     */   
/*     */   public static boolean isTextChar(char c) {
/*  72 */     return (c < 'Ā') && (TEXT_CHARS[c] != 0);
/*     */   }
/*     */   
/*     */   public static boolean isAtomChar(char c) {
/*  76 */     return (c < 'Ā') && (ATOM_CHARS[c] != 0);
/*     */   }
/*     */   
/*     */   public static boolean isAStringChar(char c) {
/*  80 */     return (c < 'Ā') && (ASTRING_CHARS[c] != 0);
/*     */   }
/*     */   
/*     */   public static boolean isCapabilityChar(char c) {
/*  84 */     return (c < 'Ā') && (CAPABILITY_CHARS[c] != 0);
/*     */   }
/*     */   
/*     */   public static boolean isQuotedSpecialChar(char c) {
/*  88 */     return (c == '\\') || (c == '"');
/*     */   }
/*     */   
/*     */   public static boolean isNumber(String s) {
/*  92 */     return isValid(s, NUMBER_CHARS);
/*     */   }
/*     */   
/*     */   public static boolean isTag(String s) {
/*  96 */     return isValid(s, TAG_CHARS);
/*     */   }
/*     */   
/*     */   public static boolean isAtom(String s) {
/* 100 */     return isValid(s, ATOM_CHARS);
/*     */   }
/*     */   
/*     */   public static boolean isText(String s) {
/* 104 */     return isValid(s, TEXT_CHARS);
/*     */   }
/*     */   
/*     */   public static long getNumber(String s) {
/* 108 */     long n = 0L;
/* 109 */     for (int i = 0; i < s.length(); i++) {
/* 110 */       char c = s.charAt(i);
/* 111 */       if (!isNumber(c)) return -1L;
/* 112 */       n = n * 10L + (c - '0');
/* 113 */       if (n < 0L) return -1L;
/*     */     }
/* 115 */     return n;
/*     */   }
/*     */   
/*     */   public static boolean isValid(String s, boolean[] chars) {
/* 119 */     for (int i = 0; i < s.length(); i++) {
/* 120 */       char c = s.charAt(i);
/* 121 */       if ((c > 'ÿ') || (chars[c] == 0)) return false;
/*     */     }
/* 123 */     return true;
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/mailclient/imap/Chars.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */